/*******************************************************************************
 * Copyright (c) 2012 Daniele Parisi.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Daniele Parisi
 *     neb.inf@gmail.com
 *     http://www.danieleparisi.com/
 ******************************************************************************/
package org.jxreport.core.views.twocols;

import org.jxreport.core.Table;
import org.jxreport.core.XMLValues;
import org.jxreport.core.views.ViewObject;
import org.jxreport.html.HTMLDivView;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class TwoColsView extends ViewObject {

	protected HTMLDivView left;
	protected HTMLDivView right;

	public TwoColsView(Element twoColsElement, Table table){
		super(twoColsElement, table);

		NodeList nl = twoColsElement.getElementsByTagName(XMLValues.LEFT_COL);
		Element leftEl = (Element)nl.item(0);
		this.left = new HTMLDivView(leftEl, null);
//		nl = leftEl.getElementsByTagName("*");
//		for (int i = 0; i < nl.getLength(); i++) {
//			Element el = (Element)nl.item(i);
//			if(el.getParentNode().getNodeName().equals(leftEl.getNodeName()))
//			{
//				HTMLReportView rv = HTMLUtils.getDOMElementToHTMLObjectClass(el, null);
//				if(rv != null)
//					this.left.getContents().add(rv);
//			}
//		}
		
		nl = twoColsElement.getElementsByTagName(XMLValues.RIGHT_COL);
		Element rightEl = (Element)nl.item(0);
		this.right = new HTMLDivView(rightEl, null);
//		nl = rightEl.getElementsByTagName("*");
//		for (int i = 0; i < nl.getLength(); i++) {
//			Element el = (Element)nl.item(i);
//			if(el.getParentNode().getNodeName().equals(rightEl.getNodeName()))
//			{
//				HTMLReportView rv = HTMLUtils.getDOMElementToHTMLObjectClass(el, null);
//				if(rv != null)
//					this.right.getContents().add(rv);
//			}
//		}
		
//		// TODO: Non permette di dare altre proprietà al tag left.
//		Element leftElement = (Element)nl.item(0);
//		this.left = HTMLUtils.getDOMElementToHTMLObjectClass(leftElement, null);
//
//		nl = textElement.getElementsByTagName(XMLValues.RIGHT_COL);
//		// TODO: Non permette di dare altre proprietà al tag right.
//		el = (Element)nl.item(0);
//		nl = el.getElementsByTagName("*");
//		Element rightElement = (Element)nl.item(0);
//
//		this.right = HTMLUtils.getDOMElementToHTMLObjectClass(rightElement, null);
	}
}
